home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_force_jump.cog < prev    next >
Text File  |  1998-02-25  |  5KB  |  202 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # FORCE_JUMP.COG
  4. #
  5. # FORCEPOWER Script - Force Jump
  6. #  Basic Power
  7. #  Bin 21
  8. #
  9. #  This ability is controlled by the length of the key press.
  10. #
  11. # [YB]
  12. #
  13. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  14.  
  15.  
  16. symbols
  17.  
  18. thing       player                           local
  19. vector      upVel                            local
  20. vector      playerVel                        local
  21. vector      newVel                           local
  22.  
  23. flex        cost=20.0                        local
  24. flex        mana                             local
  25. flex        jump                             local
  26. flex        duration                         local
  27. flex        maxDuration                      local
  28. int         rank                             local
  29.  
  30. int         attachFlags                      local
  31.  
  32. sound       jumpSound=ForceJump01.wav        local
  33. sound       jumpSound2=ForceJump02.wav       local
  34. int         channel=-1                       local
  35. flex        soundduration                    local
  36.  
  37. int         inbubble=0                       local
  38.  
  39. message     startup
  40. message     activated
  41. message     deactivated
  42. message     pulse
  43. message     newplayer
  44. message     timer
  45. message     killed
  46. message     selected
  47. message     enterbubble
  48. message     exitbubble
  49.  
  50. end
  51.  
  52. # ========================================================================================
  53.  
  54. code
  55.  
  56. startup:
  57.    player = GetLocalPlayerThing();
  58.    inbubble = 0;
  59.    SetPulse(0);
  60.    SetInvActivated(player, 21, 0);
  61.    soundduration = GetSoundLen(jumpSound);
  62.  
  63.    Return;
  64.  
  65. # ........................................................................................
  66.  
  67. activated:
  68.    if(inbubble) Return;
  69.  
  70.    // No jumping with the EWEB
  71.    if (GetCurWeapon(player) == 10) Return;
  72.  
  73.    if(IsInvActivated(player, 21)) Return;
  74.  
  75.    SetInvActivated(player, 21, 1);
  76.    mana = GetInv(player, 14);
  77.    if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
  78.    {
  79.       channel = PlaySoundThing(jumpSound, player, 1.0, -1, -1, 0x80);
  80.       ActivateBin(player, 0, 21);
  81.       SetPulse(0.5);
  82.    }
  83.  
  84.    Return;
  85.  
  86. # ........................................................................................
  87.  
  88. deactivated:
  89.    // No jumping with the EWEB
  90.    if (GetCurWeapon(player) == 10) Return;
  91.  
  92.    duration = DeactivateBin(player, 21);
  93.  
  94.    SetInvActivated(player, 21, 0);
  95.    SetPulse(0);
  96.  
  97.    if(inbubble) Return;
  98.  
  99.    if(duration < soundduration)
  100.    {
  101.       if(channel != -1)
  102.       {
  103.          StopSound(channel, 0.0);
  104.          channel = -1;
  105.       }
  106.    }
  107.  
  108.    rank = GetInv(player, 21);
  109.    maxDuration = rank * 0.35;
  110.  
  111.    // Must be attached to a world surface or thing face or on the surface of water.
  112.    attachFlags = GetAttachFlags(player);
  113.    if((attachFlags & 1) || (attachFlags & 2) || (GetPhysicsFlags(player) & 0x100000))
  114.    {
  115.       mana = GetInv(player, 14);
  116.       if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
  117.       {
  118.          PlaySoundThing(jumpSound2, player, 1.0, -1, -1, 0x80);
  119.          if(GetInv(player, 64) != 1) ChangeInv(player, 14, -cost);
  120.  
  121.          // Send a "force disturbance"...
  122.          if(!IsMulti())
  123.             SendMessageExRadius(GetThingPos(player), cost, 0x4, splash, 21, 0, 0, 0);
  124.  
  125.          // If we tap or hold to max, then do max jump.
  126.          if((duration < 0.15) || (duration > maxDuration))
  127.             duration = maxDuration;
  128.  
  129.          // Flash the twinkling stars effect
  130.          if(!(jkGetFlags(player) & 0x20))
  131.          {
  132.             jkSetPersuasionInfo(player, 14, 22);
  133.             jkSetFlags(player, 0x20);
  134.             SetTimerEx(0.33, player, 0, 0);
  135.          }
  136.  
  137.          jump = duration + 2.5;
  138.          upVel = VectorSet(0.0, 0.0, jump);
  139.  
  140.          playerVel = GetThingVel(player);
  141.          newVel = VectorAdd(upVel, playerVel);
  142.          DetachThing(player);
  143.          SetThingVel(player, newVel);
  144.  
  145.          ClearPhysicsFlags(player, 0x100000);
  146.       }
  147.    }
  148.  
  149.    Return;
  150.  
  151. # ........................................................................................
  152.  
  153. pulse:
  154.    if(GetThingHealth(player) < 1)
  155.    {
  156.       if(channel != -1) StopSound(channel, 0.1);
  157.       SetPulse(0);
  158.    }
  159.  
  160.    Return;
  161.  
  162. # ........................................................................................
  163.  
  164. selected:
  165.    jkPrintUNIString(player, 21);
  166.    Return;
  167.  
  168. # ........................................................................................
  169.  
  170. killed:
  171.    if(GetSenderRef() != player) Return;
  172.  
  173. newplayer:
  174.    SetPulse(0);
  175.    SetInvActivated(player, 21, 0);
  176.  
  177.    Return;
  178.  
  179. # ........................................................................................
  180.  
  181. enterbubble:
  182.    inbubble = 1;
  183.    //call stop_power;
  184.    Return;
  185.  
  186. # ........................................................................................
  187.  
  188. exitbubble:
  189.    inbubble = 0;
  190.    Return;
  191.  
  192. # ........................................................................................
  193.  
  194. timer:
  195.    jkClearFlags(GetSenderId(), 0x20);
  196.  
  197.    Return;
  198.  
  199. end
  200.  
  201.  
  202.